<?php 
require_once("perficature-utils.php");
insertHeader("Parse User-Agent", true);

$ua = ( array_key_exists('ua', $_GET) ? $_GET['ua'] : $_SERVER['HTTP_USER_AGENT'] );
$pbrowser = parseUseragent($ua, $browser, $v1, $v2, $v3);
?>

<p style="margin-top: 0;">
Paste a User Agent string to see how it's parsed. 
<br>
Examples: 
<a href="parse.php?ua=Mozilla%2F5.0+(Windows%3B+U%3B+Windows+NT+5.1%3B+ru%3B+rv%3A1.9.0.4)+Gecko%2F2008102920+Firefox%2F3.0.4">Firefox</a>,
<a href="parse.php?ua=Mozilla%2F4.0+(compatible%3B+MSIE+7.0%3B+Windows+NT+5.1%3B+.NET+CLR+1.1.4322%3B+.NET+CLR+2.0.50727%3B+InfoPath.2%3B)">IE</a>,
<a href="parse.php?ua=Mozilla%2F5.0+(Macintosh%3B+U%3B+Intel+Mac+OS+X+10_5_5%3B+en-us)+AppleWebKit%2F525.26.2+(KHTML%2C+like+Gecko)+Version%2F3.2+Safari%2F525.26.12">Safari</a>,
<a href="parse.php?ua=Opera%2F9.62+(Windows+NT+5.1%3B+U%3B+de)+Presto%2F2.1.1">Opera</a>,
<a href="parse.php?ua=Mozilla%2F5.0+(Windows%3B+U%3B+Windows+NT+5.1%3B+en-US)+AppleWebKit%2F525.19+(KHTML%2C+like+Gecko)+Chrome%2F1.0.154.36+Safari%2F525.19">Chrome</a>,
<a href="parse.php?ua=Mozilla%2F5.0+(iPhone%3B+U%3B+CPU+iPhone+OS+2_0_1+like+Mac+OS+X%3B+en-us)+AppleWebKit%2F525.18.1+(KHTML%2C+like+Gecko)+Version%2F3.1.1+Mobile%2F5B108+Safari%2F525.20">iPhone</a>,
<a href="parse.php?ua=Mozilla%2F5.0+(Linux%3B+U%3B+Android+1.0%3B+en-us%3B+dream)+AppleWebKit%2F525.10%2B+(KHTML%2C+like+Gecko)+Version%2F3.0.4+Mobile+Safari%2F523.12.2">Android</a>,
<a href="parse.php?ua=Mozilla%2F5.0+(Windows%3B+U%3B+Windows+NT+6.0%3B+ja%3B+rv%3A1.9.1b3pre)+Gecko%2F20081221+Shiretoko%2F3.0b3pre">Shiretoko</a>,
<a href="parse.php?ua=Mozilla%2F5.0+(SymbianOS%2F9.2%3B+U%3B+Series60%2F3.1+NokiaE51-1%2F200.34.36%3B+Profile%2FMIDP-2.0+Configuration%2FCLDC-1.1+)+AppleWebKit%2F413+(KHTML%2C+like+Gecko)+Safari%2F413">Nokia</a>,
<a href="parse.php?ua=+%09Mozilla%2F5.0+(Windows%3B+U%3B+Windows+NT+5.1%3B+en-US)+AppleWebKit%2F525.19+(KHTML%2C+like+Gecko)+Iron%2F0.2.152.0+Safari%2F12081672.525">Iron</a>,
<a href="parse.php?ua=Mozilla%2F5.0+(Windows%3B+U%3B+Windows+NT+5.1%3B+en-US%3B+rv%3A1.9.1b3pre)+Gecko%2F2008+Lunascape%2F4.9.9.98">Lunascape</a>
</p>

<form name=form1>
User Agent string:
<br>
<textarea name=ua id=ua rows=4 cols=80>
<?php echo $ua ?>
</textarea>

<br>
<input type=submit value="Submit">
</form>

<table cellpadding=2 cellspacing=0 border=0>
  <tr> 
    <td valign=top>
parse results:
<div id=uaprofilerresults style="border: 1px solid #555; padding: 2px 4px 2px 4px; margin-bottom: 16px; font-size: 1.5em; font-weight: bold;"><?php echo $pbrowser ?></div>
run your browser through <a href="test.php" style="font-size: 1.1em; text-decoration: underline; color: #933000; font-weight: bold;"><nobr>the Test</nobr></a>
    </td>
    <td style="padding-left: 150px;">
<div style="border: 1px solid #BBB; padding: 8px;">
<?php
echo genFixBrowser($_SERVER['HTTP_USER_AGENT']);
?>
</div>
    </td> 
  </tr>
</table>

<table cellpadding=2 cellspacing=0 border=0>
  <tr> <td style="padding-top: 80px;" colspan=2>compare to other services:</td> </tr>

  <tr> 
    <td style="padding-left: 40px;" align=right>UserAgentString.com:</td> 
    <td><a href="http://www.useragentstring.com/index.php?uas=<?php echo urlencode($ua) ?>"><span id=useragentstringcomresults style="font-weight: bold;"></span></a></td>
  </tr>

  <tr> 
    <td style="padding-left: 40px;" align=right>user-agent-string.info:</td> 
    <td><a href="<?php echo getUserAgentStringInfoUrl($ua, true) ?>"><span id=useragentstringinforesults style="font-weight: bold;"></span></a></td>
  </tr>

  <tr> 
    <td style="padding-left: 40px;" align=right><a href="http://browsers.garykeith.com/tools/agent-checker.asp">Browser Capabilities Project</a>:</td>
    <td>copy-and-paste the UA string above</td>
  </tr>

</table>

<script type="text/javascript">
function doFix() {
	new Image().src = "parse-fix.php?uafix=" + escape(document.form2.uafix.value) + "&uar=" + escape(document.getElementById('uaprofilerresults').innerHTML) + "&ua=" + escape(document.form1.ua.value);
	document.getElementById('uafixmsg').innerHTML = "Your fix was submitted. Thanks!";
}


function loadOtherResults() {
    var domscript = document.createElement('script');
    domscript.src = "parse-service.php?service=useragentstringcom&id=useragentstringcomresults&ua=<?php echo urlencode($ua) ?>";
    document.getElementsByTagName('head')[0].appendChild(domscript);

    domscript = document.createElement('script');
    domscript.src = "parse-service.php?service=user-agent-string-info&id=useragentstringinforesults&ua=<?php echo urlencode($ua) ?>";
    document.getElementsByTagName('head')[0].appendChild(domscript);
}

window.onload = loadOtherResults();
</script>

<?php
insertFooter(); 
?>
